home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / gtlayout / source / ltp_getdisplayclip.c < prev    next >
C/C++ Source or Header  |  1999-04-19  |  2KB  |  74 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. /*****************************************************************************/
  15.  
  16. #include <graphics/videocontrol.h>
  17.  
  18. /*****************************************************************************/
  19.  
  20. #include "Assert.h"
  21.  
  22. VOID
  23. LTP_GetDisplayClip(struct Screen *screen,WORD *left,WORD *top,WORD *width,WORD *height)
  24. {
  25.     struct TagItem tags[2] = { VTAG_VIEWPORTEXTRA_GET, NULL, TAG_DONE };
  26.  
  27.     if(!VideoControl(screen->ViewPort.ColorMap,tags))
  28.     {
  29.         struct ViewPortExtra    *vpe = (struct ViewPortExtra *)tags[0].ti_Data;
  30.         struct Rectangle         clip;
  31.  
  32.         QueryOverscan(GetVPModeID(&screen->ViewPort),&clip,OSCAN_TEXT);
  33.  
  34.         *width    = vpe->DisplayClip.MaxX - vpe->DisplayClip.MinX + 1;
  35.         *height = vpe->DisplayClip.MaxY - vpe->DisplayClip.MinY + 1;
  36.  
  37.         if(*width < clip.MaxX - clip.MinX + 1)
  38.             *width = clip.MaxX - clip.MinX + 1;
  39.  
  40.         if(*height < clip.MaxY - clip.MinY + 1)
  41.             *height = clip.MaxY - clip.MinY + 1;
  42.  
  43.         if(*width > screen->Width)
  44.             *width = screen->Width;
  45.  
  46.         if(*height > screen->Height)
  47.             *height = screen->Height;
  48.     }
  49.     else
  50.     {
  51.         *width    = screen->Width;
  52.         *height = screen->Height;
  53.     }
  54.  
  55.     *left = screen->LeftEdge;
  56.     *top  = screen->TopEdge;
  57.  
  58.     if(*left > 0)
  59.         *left = 0;
  60.     else
  61.         *left = -(*left);
  62.  
  63.     if(*top > 0)
  64.         *top = 0;
  65.     else
  66.         *top = -(*top);
  67.  
  68.     if((*left > screen->Width) || (*left < 0))
  69.         *left = 0;
  70.  
  71.     if ((*top > screen->Height) || (*top < 0))
  72.         *top = 0;
  73. }
  74.